home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / HyperCard Goodies / Serial Toolkit / Source Code / SPortBufferSize.p < prev    next >
Text File  |  1988-11-18  |  1KB  |  68 lines

  1. (*
  2.     SPortBufferSize() -- Returns the size of the current input buffer, or zero if the default buffer is
  3.         begin used.
  4.  
  5.     To compile and link this file using Macintosh Programmer's Workshop,
  6.  
  7.         pascal -w SPortBufferSize.p
  8.         link -m ENTRYPOINT -o HyperCommands -rt XFCN=7034 -sn Main=SPortBufferSize ∂
  9.             SPortBufferSize.p.o "{MPW}"Libraries:interface.o
  10.  
  11.     © Copyright 1987,88 by Apple Computer, Inc.
  12.  
  13.     Initial coding 9/87 by Harry R. Chesley.
  14. *)
  15.  
  16. {$R-}
  17.  
  18. {$S SPortBufferSize }     { Segment name must be the same as the command name. }
  19.  
  20. unit DummyUnit;
  21.  
  22. interface
  23.  
  24. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  25.  
  26. procedure EntryPoint(paramPtr: XCmdPtr);
  27.     
  28. implementation
  29.  
  30. type
  31.  
  32. Str31 = String[31];
  33.  
  34. procedure SPortBufferSize(paramPtr: XCmdPtr); forward;
  35.  
  36. procedure EntryPoint(paramPtr: XCmdPtr);
  37.  
  38.     begin
  39.         SPortBufferSize(paramPtr);
  40.     end;
  41.  
  42. procedure SPortBufferSize(paramPtr: XCmdPtr);
  43.  
  44.     var l: longInt;
  45.  
  46.     {$I XCmdGlue.inc}
  47.  
  48.     procedure Fail(errMsg: Str255); { set theResult and quit }
  49.         begin
  50.             paramPtr^.returnValue := PasToZero(errMsg);
  51.             exit(SPortBufferSize);
  52.         end;
  53.  
  54.     {$I SPortUtil.inc}
  55.  
  56.     begin
  57.         if paramPtr^.paramCount <> 0 then Fail('parameter count is not 0');
  58.  
  59.         SetUpSPortGlobals;
  60.         EnsureOpenPort;
  61.  
  62.         { Find and return the size of the current buffer (or zero if the default buffer is being used). }
  63.         if ThisSPort.inputBuffer = nil then l := 0
  64.         else l := GetPtrSize(ThisSPort.inputBuffer);
  65.         paramPtr^.returnValue := PasToZero(LongToStr(l))
  66.     end;
  67. end.
  68.